package com.gxa.zhonglong.service.impl;

import com.gxa.zhonglong.common.ExceptionCode;
import com.gxa.zhonglong.exception.BusinessException;
import com.gxa.zhonglong.mapper.AuditMapper;
import com.gxa.zhonglong.pojo.Audit;
import com.gxa.zhonglong.service.AuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author asus
 */
@Service
public class AuditServiceImp implements AuditService {
    @Autowired
    AuditMapper auditMapper = null;

    @Override
    public void insertAudit(Audit audit) {

        auditMapper.insertAudit(audit);
    }

    @Override
    public void updateByReceiptNumberAudit(Audit audit) throws BusinessException {
        Audit audit1 = auditMapper.selectByReceiptNumber(audit.getReceiptNumber());
        if (audit != null){
            auditMapper.updateByReceiptNumber(audit);
        }else {
            throw new BusinessException(ExceptionCode.DUPLICATE_CUSTOMER);
        }
    }
}
